﻿#include "NPCPage.h"

namespace Server::MirObjects
{

    NPCPage::NPCPage(const std::string &key)
    {
        Key = key;
    }

    std::string NPCPage::ArgumentParse(const std::string &key)
    {
        if (StringHelper::startsWith(key, "[@_"))
        {
            return key; //Default NPC page so doesn't use arguments in this way
        }

        Regex *r = new Regex(R"(\((.*)\))");

        Match *match = r->Match(key);
        if (!match->Success)
        {
            delete r;
            return key;
        }

//C# TO C++ CONVERTER TODO TASK: There is no C++ equivalent to 'ToString':
        key = Regex::Replace(key, r->ToString(), "()");

        std::string strValues = match->Groups[1]->Value;
        std::vector<std::string> arrValues = StringHelper::split(strValues, ',');

        Args = std::vector<std::string>();

        for (auto t : arrValues)
        {
            Args.push_back(t);
        }

        delete r;
        return key;
    }
}
